﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace map.member.lvyou
{
    public partial class newactivity : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MainGridViewBind();
        }

        private void MainGridViewBind()
        {
            RuleCode.Table.lyactivity x = RuleCode.Table.lyactivity.Find(
                                                                 " createuserid = '" + AliApi.appUserId + " '");
            this.GridView2.DataSource = x.MyTable;
            this.GridView2.DataBind();
        }

        private void bind1()
        { 
            //
        }
        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //
        }
        private void DetailGridViewBind()
        {
            RuleCode.Table.lyactivitylist x = RuleCode.Table.lyactivitylist.Find(
                                                                   " createuserid = '" + AliApi.appUserId + " '");
            this.GridView1.DataSource = x.MyTable;
            this.GridView1.DataBind();
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
           
        }

        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
            lyactivitylist uc = lyactivitylist.Find(" recid = '" + id + "'", "RECID");

            TextBox1.Text = uc.jcvaliddate.StringValue;
            TextBox9.Text = uc.jcvalidtime.StringValue;
            TextBox3.Text = uc.jcstartdate.StringValue;
            DropDownList1.SelectedValue = uc.jcpoint.StringValue;

            //TextBox1.Text = uc.lyviewpointid.ToString();
            //TextBox_long.Text = uc.taobaolong.ToString();
            //TextBox_lat.Text = uc.taobaolat.ToString();
            //Label_recid.Text = uc.RECID.ToString();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            lyactivitylist uc = lyactivitylist.Find(" 1=2 ");
                uc.New();
                uc.jcvaliddate.Value = Convert.ToDateTime(TextBox1.Text);
                uc.jcvalidtime.Value = Convert.ToInt32(TextBox9.Text);
                uc.jcstartdate.Value =  Convert.ToDateTime(TextBox3.Text);
                //uc.jcpoint.Value = DropDownList1.Text;
                //uc.valid.Value = RuleCode.Enum.NoYes.No;
                ////todo:change after finished login function
                ////finished
                //uc.createuserid = AliApi.appUserId;

                //uc.taobaolong.Value = zfunction.str2double(TextBox_long.Text);
                //uc.taobaolat.Value = zfunction.str2double(TextBox_lat.Text);
                //uc.Insert();
                //GridViewBind();
           
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //lyviewpoint x = lyviewpoint.Find(" recid = '" + Label_recid.Text + "'", "RECID");
            //x.lyviewpointid.Value = TextBox1.Text;
            //x.taobaolong.Value = zfunction.str2double(TextBox_long.Text);
            //x.taobaolat.Value = zfunction.str2double(TextBox_lat.Text);
            //x.Modify();
            //GridViewBind();
        }

        protected void GridView2_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
            lyactivity uc = lyactivity.Find(" recid = '" + id + "'", "RECID");
            MainRecId.Text = uc.RECID.StringValue;
            TextBox4.Text = uc.cbtitle.StringValue;
            Fck_gonggao.Value = Server.HtmlDecode(uc.jcdesc1.StringValue);
            Fck_gonggao0.Value = Server.HtmlDecode(uc.jcdesc2.StringValue);
            Fck_gonggao1.Value = Server.HtmlDecode(uc.jcdesc3.StringValue);
            Fck_gonggao2.Value = Server.HtmlDecode(uc.jcdesc4.StringValue);
            Fck_gonggao3.Value = Server.HtmlDecode(uc.jcdescs2.StringValue);
            DropDownList8.SelectedValue = uc.leixing.StringValue;
            DropDownList13.SelectedValue = uc.lyviewpointrecid1.StringValue;
            DropDownList17.SelectedValue = uc.lyviewpointrecid2.StringValue;
            DropDownList21.SelectedValue = uc.lyviewpointrecid3.StringValue;
            DropDownList25.SelectedValue = uc.lyviewpointrecid4.StringValue;
            DropDownList29.SelectedValue = uc.lyviewpointrecid5.StringValue;
            DropDownList7.SelectedValue = uc.qiangdu.StringValue;
            DropDownList5.SelectedValue = uc.renqun.StringValue;
            TextBox5.Text = uc.renshu.StringValue;
            TextBox6.Text = uc.rjxf.StringValue;
            DropDownList6.SelectedValue = uc.shiduan.StringValue;
            DropDownList9.SelectedValue = uc.xingbie.StringValue;
            TextBox8.Text = uc.taobaolat_jihe.StringValue;
            TextBox7.Text = uc.taobaolong_jihe.StringValue;
           
            
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            lyactivity uc = lyactivity.Find(" 1=2 ");
            uc.New();
            uc.createduserid = AliApi.appUserId;
            uc.cbtitle = TextBox4.Text;
            uc.cbstatus = "New";
            uc.jcdesc1 = Fck_gonggao.Value;
            uc.jcdesc2 = Fck_gonggao0.Value;
            uc.jcdesc3 = Fck_gonggao1.Value;
            uc.jcdesc4 = Fck_gonggao2.Value;
            uc.jcdescs2 = Fck_gonggao3.Value;
            
            uc.jcdescs1 = "";
            uc.jcpoint =22;
            uc.leixing = DropDownList8.SelectedValue;
            uc.lyactivityid = "";
            uc.lyviewpointrecid1 = DropDownList13.SelectedValue;
            uc.lyviewpointrecid2 = DropDownList17.SelectedValue;
            uc.lyviewpointrecid3 = DropDownList21.SelectedValue;
            uc.lyviewpointrecid4 = DropDownList25.SelectedValue;
            uc.lyviewpointrecid5 = DropDownList29.SelectedValue;
            uc.qiangdu = DropDownList7.SelectedValue;
            uc.renqun = DropDownList5.SelectedValue;
            uc.renshu = Convert.ToInt32(TextBox5.Text);
            uc.rjxf = TextBox6.Text;
            uc.shiduan = DropDownList6.SelectedValue;
            uc.xingbie = DropDownList9.SelectedValue;
            uc.taobaolat_end = 1;
            uc.taobaolong_end = 2;
            uc.taobaolat_jihe = Convert.ToDouble(TextBox8.Text);
            uc.taobaolong_jihe = Convert.ToDouble(TextBox7.Text);
            uc.taobaolat_start = 5;
            uc.taobaolong_start = 6;

            uc.Insert();
            MainGridViewBind();

           
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            lyactivity uc = lyactivity.Find(" recid = '" + MainRecId.Text + "'", "RECID");
          
            
            uc.cbtitle = TextBox4.Text;
            uc.cbstatus = "New";
            uc.jcdesc1 = Fck_gonggao.Value;
            uc.jcdesc2 = Fck_gonggao0.Value;
            uc.jcdesc3 = Fck_gonggao1.Value;
            uc.jcdesc4 = Fck_gonggao2.Value;
            uc.jcdescs2 = Fck_gonggao3.Value;

            uc.jcdescs1 = "";
            uc.jcpoint = 22;
            uc.leixing = DropDownList8.SelectedValue;
            uc.lyactivityid = "";
            uc.lyviewpointrecid1 = DropDownList13.SelectedValue;
            uc.lyviewpointrecid2 = DropDownList17.SelectedValue;
            uc.lyviewpointrecid3 = DropDownList21.SelectedValue;
            uc.lyviewpointrecid4 = DropDownList25.SelectedValue;
            uc.lyviewpointrecid5 = DropDownList29.SelectedValue;
            uc.qiangdu = DropDownList7.SelectedValue;
            uc.renqun = DropDownList5.SelectedValue;
            uc.renshu = Convert.ToInt32(TextBox5.Text);
            uc.rjxf = TextBox6.Text;
            uc.shiduan = DropDownList6.SelectedValue;
            uc.xingbie = DropDownList9.SelectedValue;
            uc.taobaolat_end = 1;
            uc.taobaolong_end = 2;
            uc.taobaolat_jihe = Convert.ToDouble(TextBox8.Text);
            uc.taobaolong_jihe = Convert.ToDouble(TextBox7.Text);
            uc.taobaolat_start = 5;
            uc.taobaolong_start = 6;

            uc.Modify();
            MainGridViewBind();
        }
    }
}
